package com.project.ToDone;

import java.util.ArrayList;
import java.util.List;

import android.content.Context;
import android.graphics.Color;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

/**
 * ArrayAdaptor that handles events, allows
 * for the change of color to stay even in different views
 * 
 * 
 * @author Sean Wheeler
 *
 * @param <T>
 */

public class EventArrayAdapter<T> extends ArrayAdapter<T> {
	
	/**
	 * Constructor, passed in list of event objects and the contexts
	 * 
	 * @param context
	 * @param textViewResourceId
	 * @param objects
	 */
	public EventArrayAdapter(Context context, int textViewResourceId,
			List<T> objects) {
		super(context, textViewResourceId, objects);
		// TODO Auto-generated constructor stub
	}

	/**
	 * Displays the view, with correct event coloring
	 * 
	 */
	public View getView(int position, View convertView, ViewGroup parent)
	{
		TextView tv = (TextView)super.getView(position, convertView, parent);
		
		if(((Event)getItem(position)).getCompleted())
		{
			tv.setTextColor(Color.BLACK);
		}
		else
		{
			tv.setTextColor(Color.WHITE);
		}
		
		return tv;
		
	}

}
